
$(document).ready(function(){
    //var tlfyMaxScore = 248.5;
    $('#cetTypeInput').change(function(){
        var p1=$(this).children('option:selected').val();//这就是selected的值
        if(p1=="井柏然"){$("#startphoto").attr("src","images/1.jpg")}
        if(p1=="鹿晗"){$("#startphoto").attr("src","images/2.jpg")}
        if(p1=="吴亦凡"){$("#startphoto").attr("src","images/3.jpg")}
        if(p1=="宋仲基"){$("#startphoto").attr("src","images/4.jpg")}
        if(p1=="李易峰"){$("#startphoto").attr("src","images/5.jpg")}
        if(p1=="胡歌"){$("#startphoto").attr("src","images/6.jpg")}
        if(p1=="陈翔"){$("#startphoto").attr("src","images/7.jpg")}
        if(p1=="霍建华"){$("#startphoto").attr("src","images/8.jpg")}
        });
    $("#createImgBtn").on("click",function() {
        var youName = $("#youNameInput").val();
        var schoole = $("#schooleInput").val();
        //var cetType = $("#cetTypeInput").find("option:selected").html();
        if (isNull(youName)) {
            alert("请填写姓名");
            return;
        }
        if (isNull(schoole)) {
            alert("请填写学校");
            return;
        }
        $("#youName").html(youName);
        $("#schoole").html(schoole);
        $("div.collectInfo").hide();
        $("div.cetPanel").show();
        cavensCreate();
    });
});

function cavensCreate(){
    html2canvas( document.body ,{
        onrendered: function(canvas){
            $("div.cetPanel").hide();
            var image = new Image();
            image.src = canvas.toDataURL("image/png");
            image.width = $(document).width();
            document.body.appendChild(image);
            $("body,html").css("background","none");
            setTimeout(function(){
                alert("请截图发朋友圈吧");
            },0);
        },
        background:"#ffffff",
        height:677,
        width:440
    });
}

function isNull(val){
    if(!val || val=="null" || val=="undefined"){
        return true;
    }
    return false;
}

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
  WeixinJSBridge.call('hideOptionMenu');
}, false);